//
//  SWProfileHeaderView.swift
//  ChildStory
//
//  Created by linhan on 2016/12/14.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation
import UIKit
class SWProfileHeaderView: UIView
{
    weak var delegate:ClickActionDelegate?
    
    var image:Any? {
        didSet{
            _avatarView.image = image
        }
    }
    
    private var _avatarView = CircleAvatar(radius: 38, borderWidth: 1, borderColor: UIColor(hex: 0xe9e9e9))
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setup()
    {
        backgroundColor = UIColor.white
        
        let imageView = UIImageView(image: UIImage(named:"profile_img_mine.jpg"))
        imageView.frame = bounds
        addSubview(imageView)
        
        let avatarTapGesture = UITapGestureRecognizer(target: self, action: #selector(avatarTapped))
        _avatarView.center = CGPointMake(width - 50, 70)
        _avatarView.addGestureRecognizer(avatarTapGesture)
        addSubview(_avatarView)
    }
    
    @objc private func avatarTapped()
    {
        delegate?.view(self, click: CallbackAction.Tap, argument: nil)
    }
    
}
